//
//  NSDate+YLAddDateInfo.h
//  yuLink
//
//  Created by aiwoba on 2021/3/15.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSDate (YLAddDateInfo)
/**
 计算时间差 以 小时 为单位

 @param nowDate 当前的时间
 @param lastTimeDate 最后一次记录时间
 @return 时间差
 */
+(long  int )dateGetTimeDifferenceNowDate:(NSDate *)nowDate lastTimeDate:(NSDate *)lastTimeDate;
/**
 格式化时间类型 为  服务器传的年月日时分秒

 @param timestampStr 服务器给的
 @param format 想要格式化的类型
 @return 格式化好的时间字符串
 */
+(NSString *)dateFormatterTimeStr:(NSString *)timestampStr andFormatter:(NSString *)format;

/**
 计算时间差 以 小时 为单位
 
 @param startDate  开始时间
 @param endTimeDate 结束时间
 @return 时间差
 */
+(NSMutableString *)dateGetTimeDifferenceStartDate:(NSDate *)startDate endTimeDate:(NSDate *)endTimeDate;
//timestamp 时间戳
+(NSDate *)dateTimesDateWithTime:(long long int)timestamp andFormatter:(NSString *)format;
///timestampStr 服务器给的字段
+(NSDate *)dateTimesDateWithTimeString:(NSString *)timestampStr andFormatter:(NSString *)format;
///获取当前时间戳有两种方法(以秒为单位)
+(NSString *)dateGetNowTimeTimestampSecond;
///获取当前时间戳  （以毫秒为单位）
+(NSString *)dateGetNowTimeTimestampStrMillisecond;
///获取当前时间戳  （以毫秒为单位）
+(NSDate *)dateGetNowTimeTimestampStrMillisecondDate;

//+(NSDate * )dateAfterLocalDateForlocalDate:(NSDate *)locaDate Year:(NSInteger )year Month:(NSInteger )month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;

-(NSString *)lunarHoliDayDate:(NSDate *)date;

-(BOOL)inFestival;//当前处于除夕,春节 除夕~元宵节

@property (nonatomic, readonly) NSInteger year; ///< Year component
@property (nonatomic, readonly) NSInteger month; ///< Month component (1~12)
@property (nonatomic, readonly) NSInteger day; ///< Day component (1~31)
@property (nonatomic, readonly) NSInteger hour; ///< Hour component (0~23)
@property (nonatomic, readonly) NSInteger minute; ///< Minute component (0~59)
@property (nonatomic, readonly) NSInteger second; ///< Second component (0~59)
@property (nonatomic, readonly) NSInteger nanosecond; ///< Nanosecond component
@property (nonatomic, readonly) NSInteger weekday; ///< Weekday component (1~7, first day is based on user setting)
@property (nonatomic, readonly) NSInteger weekdayOrdinal; ///< WeekdayOrdinal component
@property (nonatomic, readonly) NSInteger weekOfMonth; ///< WeekOfMonth component (1~5)
@property (nonatomic, readonly) NSInteger weekOfYear; ///< WeekOfYear component (1~53)
@property (nonatomic, readonly) NSInteger yearForWeekOfYear; ///< YearForWeekOfYear component
@property (nonatomic, readonly) NSInteger quarter; ///< Quarter component
@property (nonatomic, readonly) BOOL isLeapMonth; ///< Weather the month is leap month
@property (nonatomic, readonly) BOOL isLeapYear; ///< Weather the year is leap year
@property (nonatomic, readonly) BOOL isToday; ///< Weather date is today (based on current locale)
@property (nonatomic, readonly) BOOL isYesterday; ///< Weather date is yesterday (based on current locale)

/**
 Returns a date representing the receiver date shifted later by the provided number of years.
 
 @param years  Number of years to add.
 @return Date modified by the number of desired years.
 */
- (nullable NSDate *)dateByAddingYears:(NSInteger)years;

/**
 Returns a date representing the receiver date shifted later by the provided number of months.
 
 @param months  Number of months to add.
 @return Date modified by the number of desired months.
 */
- (nullable NSDate *)dateByAddingMonths:(NSInteger)months;

/**
 Returns a date representing the receiver date shifted later by the provided number of weeks.
 
 @param weeks  Number of weeks to add.
 @return Date modified by the number of desired weeks.
 */
- (nullable NSDate *)dateByAddingWeeks:(NSInteger)weeks;

/**
 Returns a date representing the receiver date shifted later by the provided number of days.
 
 @param days  Number of days to add.
 @return Date modified by the number of desired days.
 */
- (nullable NSDate *)dateByAddingDays:(NSInteger)days;

/**
 Returns a date representing the receiver date shifted later by the provided number of hours.
 
 @param hours  Number of hours to add.
 @return Date modified by the number of desired hours.
 */
- (nullable NSDate *)dateByAddingHours:(NSInteger)hours;

/**
 Returns a date representing the receiver date shifted later by the provided number of minutes.
 
 @param minutes  Number of minutes to add.
 @return Date modified by the number of desired minutes.
 */
- (nullable NSDate *)dateByAddingMinutes:(NSInteger)minutes;

/**
 Returns a date representing the receiver date shifted later by the provided number of seconds.
 
 @param seconds  Number of seconds to add.
 @return Date modified by the number of desired seconds.
 */
- (nullable NSDate *)dateByAddingSeconds:(NSInteger)seconds;
/**
 计算时间差  总分钟
 @param startDate  开始时间
 @param endTimeDate 结束时间
 @return 时间差
 */
+(long long )dateTotalMinuteTimeDifferenceStartDate:(NSDate *)startDate endTimeDate:(NSDate *)endTimeDate;
/**
 计算时间差  总秒数
 @param startDate  开始时间
 @param endTimeDate 结束时间
 @return 时间差
 */
+(long long )dateTotalSecondTimeDifferenceStartDate:(NSDate *)startDate endTimeDate:(NSDate *)endTimeDate;
///获取当前时间的字符串 @"YYYY-MM-dd HH:mm:ss SSS"
+(NSString *)dateGetCurrentTimeWithFormatterSting:(NSString *)formatterString;
+(NSString *)dateGetCurrentTimeWithFormatterStingAddRandomNum:(NSString *)formatterString;
/**
 计算时间差  天/时/分
 @param startDate  开始时间
 @param endTimeDate 结束时间
 @return 时间差
 */
+(NSString *)dateTotalTimeDifferenceStartDate:(NSDate *)startDate endTimeDate:(NSDate *)endTimeDate;

/**
 计算时间差   
 @param startDate  开始时间
 @param endTimeDate 结束时间
 @return 时间差
 */
+(NSDateComponents *)dateComponentsDifferenceStartDate:(NSDate *)startDate endTimeDate:(NSDate *)endTimeDate;


@end

NS_ASSUME_NONNULL_END
